package com.study.lxy.threadpool;

import org.junit.Test;

public class MyThreadPoolTest {

    @Test
    public void test1(){
        ThreadPool threadPool = new MyThreadPool();
        for(int i = 0;i < 100;i++){
            MyJob job = new MyJob();
            threadPool.execute(job);
        }
        long currentTime = System.currentTimeMillis();

        while (threadPool.getJobSize() > 0){
            //System.out.println("job size : " + threadPool.getJobSize());
            try {
                Thread.sleep(5);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        };
        System.out.println("cost time : " + (System.currentTimeMillis() - currentTime));

    }

    class MyJob implements Runnable{

        @Override
        public void run() {
            System.out.println("this is the job excuted by : " + Thread.currentThread());
            try {
                Thread.sleep(500);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }

}
